package com.lyf.config;

import com.lyf.beans.entity.Cat;
import com.lyf.beans.entity.Person;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @AUTHOR LYF
 * @DATE 2022/5/13
 * @VERSION 1.0
 * @DESC
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
         System.out.println("postProcessBeforeInitialization");
         if(bean instanceof Cat){
             System.out.println("cat....");
         }else if(bean instanceof Person){
             System.out.println("person....");
         }
         return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessAfterInitialization");
        return bean;
    }
}
